from common import info
from config import CHANNEL_DBG

class Row(list):
    def __init__(self, monomial, row_num, size = 0, what_to_fill = 0):
        list.__init__(self)
        self.monomial = monomial
        self.row_num = row_num
        self.added_row = [row_num]
        self.size = size

        for i in range(size):
            self.append(what_to_fill)

    def add(self, row, row_num):
        for i in range(self.size):
            self[i] ^= row[i]

        for item in row.added_row:
            if item in self.added_row:
                # two identical row add together is a zero row
                self.added_row.remove(item)
            else:
                self.added_row.append(item)

        info(CHANNEL_DBG, 'recording row %s to row %s\'s answer' % (row_num, self.row_num))
        info(CHANNEL_DBG, 'answer of pivot row %s is %s' % (row_num, row.added_row))
        info(CHANNEL_DBG, 'answer of row %s is now %s' % (self.row_num, self.added_row))


